// pages/index/reg_company/reg_company.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isShow: true, //控制收起展开
    isShow2: true, //控制收起展开
    istrue: false,
    // 公司类型
    items: [{
      value: 'USA',
      name: '有限公司',
      money: 498,
      id: 0

    },
    {
      value: 'CHN',
      name: '合作企业',
      money: 498,
      id: 1
    },
    {
      value: 'BRA',
      name: '分公司',
      money: 498,
      id: 2
    },
    {
      value: 'JPN',
      name: '子公司',
      money: 498,
      id: 3
    },
    {
      value: 'ENG',
      name: '个人独资',
      money: 498,
      id: 4
    },
    {
      value: 'FRA',
      name: '集团公司',
      money: 1998,
      id: 5
    },
    ],

    // 地址挂靠
    site: [{
      value: 'bao',
      name: '包地址',
      money: 2,
      id: 0
    },
    {
      value: 'bubao',
      name: '不包地址',
      money: 1,
      id: 1
    }
    ],

    // 选择区域
    array: [
      { id: 0, name: '奉贤区', money: 0, money2: 0 }, { id: 1, name: '青浦区 ', money: 0, money2: 0 },
      { id: 2, name: '松江区 ', money: 0, money2: 0 }, { id: 3, name: '崇明区 ', money: 0, money2: 0 },
      { id: 4, name: '金山区 ', money: 0, money2: 0 }, { id: 5, name: '浦东新区 ', money: 1998, money2: 4998 },
      { id: 6, name: '黄浦区', money: 2000, money2: 15000 }, { id: 7, name: '徐汇区', money: 2000, money2: 15000 },
      { id: 8, name: '长宁区', money: 1500, money2: 12000 }, { id: 9, name: '静安区 ', money: 1500, money2: 10000 },
      { id: 10, name: '普陀区 ', money: 1000, money2: 3000 }, { id: 11, name: '虹口区 ', money: 800, money2: 1500 },
      { id: 12, name: '杨浦区 ', money: 800, money2: 1200 }, { id: 13, name: '闵行区 ', money: 498, money2: 798 },
      { id: 14, name: '宝山区 ', money: 0, money2: 598 }, { id: 15, name: '嘉定区 ', money: 798, money2: 1598 },



    ],
    index: 0,

    // 财务服务
    finance: [{
      value: 'lingshenbao',
      name: '零申报',
      money: 198,
      id: 0,
      number: '3',

      month: '月'
    },
    {
      value: 'xiaoguimo',
      name: '小规模',
      money: 298,
      id: 1,
      number: '3',
      month: '月'
    },
    {
      value: 'yiban',
      name: '一般纳税人',
      money: 498,
      id: 2,
      number: '3',
      month: '月'
    },
    {
      value: 'buxuyao',
      name: '不需要',
      money: 0,
      id: 3,
      number: '3',
      month: '月'
    },
    ],

    // 缴费周期
    pay_fees: [{
      value: 'jidu',
      name: '季度',
      number: 3,
      id: 0
    },
    {
      value: 'bannian',
      name: '半年',
      number: 6,
      id: 1
    },
    {
      value: '1nian',
      name: '1年送一个月',
      number: 12,
      id: 2
    },
    {
      value: '2nian',
      name: '2年送三个月',
      number: 24,
      id: 3
    },
    ],
    //缴费周期月份
    pay_fess_month: [
      {
        number: 3
      },
      {
        number: 6
      },
      {
        number: 12
      },
      {
        number: 24
      }
    ],

    // 财务增值服务
    checkboxItems: [{
      value: 'USA',
      name: '账本账册',
      id: 0,
      checked: false,
      money: '100',
      money2: '100',
      money3: '100',
      cycle: '年',


    },
    {
      value: 'CHN',
      name: '汇算清缴',
      id: 1,
      checked: false,
      money: '98',
      money2: '300',
      money3: '500',
      cycle: '次'
    },
    {
      value: 'BRA',
      name: '年检公示',
      id: 2,
      checked: false,
      money: '350',
      money2: '350',
      money3: '350',
      cycle: '次'
    },
    {
      value: 'JPN',
      name: '税盘托管',
      id: 3,
      checked: false,
      money: '50',
      money2: '65',
      money3: '100',
      cycle: '月',
      num: 3
    },
    {
      value: 'ENG',
      name: '财务额外费用',
      id: 4,
      checked: false,
      money: '100',
      money2: '100',
      money3: '100',
      cycle: '月',
      num: 3
    },

    ],
    checkeds: [
      {
        name: '账本账册'
      },
      {
        name: '汇算清缴'
      },
      {
        name: '年检公示'
      },
      {
        name: '税盘托管'
      },
      {
        name: '财务额外费用'
      }
    ],

    //增值服务
    addServer: [{
      value: 'yinzhang',
      name: '印章刻制',
      id: 0,
      money: '200'
    },
    {
      value: 'shuizhong',
      name: '税种核定',
      id: 1,
      money: '0'
    },
    {
      value: 'yinghang',
      name: '银行开户',
      id: 2,
      money: '0'
    },
    {
      value: 'yuming',
      name: '域名申请',
      id: 3,
      money: '0'
    },
    {
      value: 'shangbiao',
      name: '商标申请',
      id: 4,
      money: '588'
    }
    ],

    //帮助信息

    helpText: [{
      title: '公司类型',
      content: '有限责任公司，简称有限公司，中国的有限责任公司是指根据《中华人民共和国公司登记管理条例》规定登记注册，由五十个以下的股东出资设立，每个股东以其所认缴的出资额为限对公司承担有限责任，公司法人以其全部资产对公司债务承担全部责任的经济组织。'
    },
    {
      title: '地址挂靠',
      content: '公司注册地址是在公司营业执照上登记的“住址”，一般情况下，公司以其主要办事机构所在地为住所，不同的城市对注册地址的要求也不一样，具体应以当地工商局要求为准。'
    },
    {
      title: '选择区域',
      content: '有限责任公司，简称有限公司，中国的有限责任公司是指根据《中华人民共和国公司登记管理条例》规定登记注册，由五十个以下的股东出资设立，每个股东以其所认缴的出资额为限对公司承担有限责任，公司法人以其全部资产对公司债务承担全部责任的经济组织。'
    },
    {
      title: '财务服务',
      content: '专业财务为您代账服务。零申报为无任何业务往来。小规模为正常开票企业。'
    },
    {
      title: '缴费周期',
      content: '您可以选择更适合您的缴费周期，当然缴费周期多，我们可以给予您更多的优惠！我们建议您1年一交，这样我们可以帮您在企业年报，汇算清缴一起服务。'
    },
    {
      title: '财务增值服务',
      content: '企业每年都必须要准时参加企业年报，汇算清缴等。'
    },
    {
      title: '增值服务',
      content: '您若是没有时间办理，让我们为您做更多！'
    }
    ],
    tems: {}

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var items = this.data.items;
    var site = this.data.site;

    var array = this.data.array;

    var finance = this.data.finance;

    var pay_fees = this.data.pay_fees;
    var checkboxItems = this.data.checkboxItems;
    //console.log(array)
    //console.log(this.data.array[0])
    items[0].checked = true;

    site[0].checked = true;

    finance[0].checked = true;

    pay_fees[0].checked = true;

    if (pay_fees[0].checked == true) {

      checkboxItems[0].color = '#3296fa'
      checkboxItems[1].color = '#3296fa'
      checkboxItems[2].color = '#3296fa'

    } else {
      checkboxItems[0].color = '#fff'
      checkboxItems[1].color = '#fff'
      checkboxItems[2].color = '#fff'
    }
    //公司类型
    var tems = []
    if (items[0].checked == true) {

      var tt = {
        money: items[0].money,
        name: items[0].name
      }
      tems.push(tt)
    }
    //地址挂靠
    var tems2 = []
    if (site[0].checked == true) {

      var tt = {
        money: site[0].money,
        name: site[0].name
      }
      tems2.push(tt)
    }
    //财务服务
    var tems3 = []
    if (finance[0].checked == true) {

      var tt = {
        money: finance[0].money,
        name: finance[0].name,
        month: finance[0].month,
        number: finance[0].number
      }
      if (tt.money == 0) {

      } else {
        tt.money = '￥' + tt.money + 'x'
        tems3.push(tt)

      }

    }

    //区域选择

    //var index = e.detail.value;
    let money = this.data.array[this.data.index].money

    let name = this.data.array[this.data.index].name

    var array = this.data.array;

    //console.log(this.data.array[this.data.index])
    //console.log(array[0].name)

    var tems4 = []
    if (name == '奉贤区') {

      var tt = {
        money: array[0].money,
        name: array[0].name
      }
      if (tt.money == 0) {
        tt.money = '免费'
        //console.log('免费')
        tems4.push(tt)
      }
      //console.log(tt)

    }

    //缴费周期

    var tems5 = []
    if (pay_fees[0].checked == true) {
      var tt = {

        name: pay_fees[0].name
      }
      tems5.push(tt)
    }
    var tems6 = []


    if (checkboxItems[0].color == '#3296fa') {
      var tt = {

        name: ''
      }
      tems6.push(tt)
    }





    //var radioName = e.detail.value
    //console.log(tems)
    this.setData({
      items: items,
      tems: tems,
      tems2: tems2,
      tems3: tems3,
      tems4: tems4,
      tems5: tems5,
      tems6: tems6,
      site: site,
      finance: finance,
      pay_fees: pay_fees,
      checkboxItems: checkboxItems,
    })


  },
  //帮助提示框
  heleimg: function (e) {

    let helpText = this.data.helpText

    let listId = e.currentTarget.dataset.list
    //console.log(this.data.helpText)

    switch (listId) {
      case '0':
        wx.showModal({
          title: helpText[0].title,
          content: helpText[0].content,
        })
        break
      case '1':
        wx.showModal({
          title: helpText[1].title,
          content: helpText[1].content,
        })
        break
      case '2':
        wx.showModal({
          title: helpText[2].title,
          content: helpText[2].content,
        })
        break
      case '3':
        wx.showModal({
          title: helpText[3].title,
          content: helpText[3].content,
        })
        break
      case '4':
        wx.showModal({
          title: helpText[4].title,
          content: helpText[4].content,
        })
        break
      case '5':
        wx.showModal({
          title: helpText[5].title,
          content: helpText[5].content,
        })
        break
      case '6':
        wx.showModal({
          title: helpText[6].title,
          content: helpText[6].content,
        })
        break
    }


  },
  //控制展开和收缩
  unfold: function (e) {


    this.setData({
      isShow: !this.data.isShow
    })

  },
  // 选中标签点击事件
  company_list: function (e) {

    var eid = e.currentTarget.dataset.current;
    var index = e.currentTarget.dataset.id;
    //console.log(index)
    var items = this.data.items;
    var site = this.data.site;
    var array = this.data.array;

    var finance = this.data.finance;
    var pay_fees = this.data.pay_fees;

    var checkboxItems = this.data.checkboxItems;
    //console.log(index)
    //console.log(e.currentTarget.dataset.index)
    var tems = []

    //console.log(eid)


    if (index == 0) {
      //公司类型
      for (var s = 0; s < items.length; s++) {
        if (eid == this.data.items[s].id) {
          //console.log(eid)
          //console.log(items[s].name)


          var tt = {
            money: items[s].money,
            name: items[s].name
          }
          tems.push(tt)

          this.setData({
            tems: tems
          })

          wx.setStorageSync('key', tems)

        } else {

        }
      }
      this.moneys(tems)

    } else if (index == 1) {
      //地址挂靠
      for (var s = 0; s < site.length; s++) {
        if (eid == this.data.site[s].id) {
          //console.log(eid)
          //console.log(site[s].name)


          var tems2 = []
          var tt = {
            name: site[s].name,
            money: site[s].money
          }

          tems2.push(tt)

          this.setData({
            tems2: tems2,

          })



          let id = this.data.array[this.data.index].id
          var tems4 = []

          if (eid == 0) {
            for (var a = 0; a < array.length; a++) {
              if (id == array[a].id) {
                var tt = {
                  money: array[a].money2,
                  name: array[a].name
                }

                if (tt.money == 0) {
                  //console.log(tt.money)  

                  //console.log('你个穷光蛋')

                  tt.money = '免费'
                  tems4.push(tt)

                } else {
                  tt.money = '￥' + tt.money
                  tems4.push(tt)

                  //console.log(tt.money)

                }
                //tems4.push(tt)
                this.setData({
                  tems4: tems4
                })
                //console.log(id)

              }


              //console.log(array[s])
            }
            //console.log('包地址')
          } else if (eid == 1) {

            for (var a = 0; a < array.length; a++) {

              if (id == array[a].id) {
                var tt = {
                  money: array[a].money,
                  name: array[a].name
                }

                if (tt.money == 0) {
                  //console.log(tt.money)  

                  //console.log('你个穷光蛋')
                  console.log(tt)
                  tt.money = '免费'
                  tems4.push(tt)

                } else {

                  tt.money = '￥' + tt.money
                  tems4.push(tt)

                  //console.log(tt.money)

                }
                //tems4.push(tt)
                this.setData({
                  tems4: tems4
                })
                //console.log(id)

              }
            }

          }



        }


      }

      this.moneys(tems2)

    } else if (index == 3) {

      //财务服务
      for (var s = 0; s < finance.length; s++) {

        //console.log(eid == this.data.finance[s].id)

        if (eid == this.data.finance[s].id) {
          //console.log(eid)
          //console.log(finance[s].name)


          for (var i = 0; i < pay_fees.length; i++) {

            if (finance[s].name == '不需要') {

              console.log('我要清空')

              if (pay_fees[i].checked == true) {

                //console.log('现在选中的是' + pay_fees[i].name)
                var tems5 = []

                var tt = {

                  name: 0,

                }
                // console.log(tt)
                // var s=0
                // s = parseInt(tt.money) * parseInt(tt.number)
                // console.log(s)

                tems5.push(tt)

                this.setData({
                  tems5: tems5
                })


              }

            } else {

              if (pay_fees[i].checked == true) {

                //console.log('现在选中的是' + pay_fees[i].name)
                var tems3 = []

                var tt = {
                  money: finance[s].money,
                  name: finance[s].name,
                  month: finance[s].month,
                  number: this.data.pay_fess_month[i].number
                }
                // console.log(tt)
                // var s=0
                // s = parseInt(tt.money) * parseInt(tt.number)
                // console.log(s)
                if (tt.money == 0) {

                  tt.money = '免费'
                  tt.month = ''
                  tt.number = ''
                  tems3.push(tt)

                } else {
                  tt.money = '￥' + tt.money + 'x'
                  tems3.push(tt)
                }


                this.setData({
                  tems3: tems3
                })

                var tems5 = []
                var tts = {
                  number: pay_fees[i].number,
                  name: pay_fees[i].name,
                }
                tems5.push(tts)
                this.setData({
                  tems5: tems5
                })
              }

            }




          }
          //wx.setStorageSync('key', tems3)

        } else {

        }
      }
      this.moneys(tems3)

      //console.log('3')




    } else if (index == 4) {

      //缴费周期
      for (var s = 0; s < pay_fees.length; s++) {

        //console.log(eid == this.data.finance[s].id)

        if (eid == this.data.pay_fees[s].id) {
          //console.log(eid)
          //console.log(finance[s].name)

          for (var i = 0; i < finance.length; i++) {
            if (finance[i].checked == true) {
              var tems3 = []
              var tts = {
                number: this.data.pay_fess_month[s].number,
                money: finance[i].money,
                name: finance[i].name,
                month: finance[i].month,

              }
              //console.log(parseInt(tts.money) * tts.number)
              // var s = 0
              // s = parseInt(tts.money) * tts.number
              // console.log(s)
              if (tts.money == 0) {

              } else {
                tts.money = '￥' + tts.money + 'x'

                tems3.push(tts)
              }


              //console.log(tts)

              this.setData({
                tems3: tems3
              })

              //console.log('当前选中的是' + finance[i].name + finance[i].id)

            }


          }


          var tems5 = []
          var tt = {
            number: pay_fees[s].number,
            name: pay_fees[s].name,

          }
          tems5.push(tt)


          // console.log(tt)
          // if (tt.money == 0) {

          //   tt.money = '免费'
          //   tt.month = ''
          //   tt.number = ''
          //   tems5.push(tt)

          // } else {
          //   tt.money = '￥' + tt.money + 'x'
          //   tems5.push(tt)
          // }


          this.setData({
            tems5: tems5
          })




        }
        this.moneys(tems5)
      }


    } else if (index == 5) {

    }

    //console.log(tems.money+tems2.money)
    // var Tem = tems + tems

    //var Tem = []
    //Tem.push(tems,tems2)

    //console.log(Tem)
    //this.moneys(tems)
    // this.moneys()

  },
  //点击事件后调用方法
  moneys: function (a) {


    //console.log(a)

    var as = a

    var company = wx.getStorageSync('key')

    var monyes = 0
    //数组中的数字受数组影响 parseInt(company[0].money)需要转化为数字
    //monyes = parseInt(company[0].money) + parseInt(as[0].money)

    //console.log(monyes)


    // this.setData({
    //   moneys:moneys
    // })







  },
  // 公司类型
  radioChange: function (e) {

    //var eid = e.currentTarget.dataset.id

    //console.log(e) 
    //console.log(e)  

    var items = this.data.items;

    var radioName = e.detail.value


    var tems = []

    for (var i = 0; i < items.length; ++i) {
      items[i].checked = items[i].value == e.detail.value
      if (items[i].value == radioName) {

        //console.log(items[i].money)
        //console.log(items[i].name)
        var tt = {
          money: items[i].money,
          name: items[i].name
        }

      }
      // var tem = {
      //   moneys:items[i].money,
      //   Names:items[i].name

      // }
      tems.push(tt)

    }
    //console.log(tems)


    //var radioName = e.detail.value
    //console.log(items)

    this.setData({
      items: items,


    });


  },

  // 地址挂靠
  radioChange2: function (e) {

    var site = this.data.site;
    for (var i = 0; i < site.length; ++i) {
      site[i].checked = site[i].value == e.detail.value

    }
    //console.log(site)

    this.setData({
      site: site
    });

  },

  // 选择区域
  bindPickerChange: function (e) {

    var index = e.detail.value;
    let money = this.data.array[index].money
    let name = this.data.array[index].name
    let id = this.data.array[index].id

    var site = this.data.site;

    var array = this.data.array;
    //console.log(array)
    var tems4 = []

    for (var a = 0; a < array.length; a++) {

      if (index == this.data.array[a].id) {

        if (site[0].checked == true) {

          for (var s = 0; s < site.length; s++) {

            if (site[s].name == '包地址') {

              var tt = {
                money: array[a].money2,
                name: array[a].name
              }
              //console.log(tt.money == 0)  

              if (tt.money == 0) {
                //console.log(tt.money)  

                //console.log('你个穷光蛋')

                tt.money = '免费'
                tems4.push(tt)

              } else {
                tt.money = '￥' + tt.money
                tems4.push(tt)

                //console.log(tt.money)

                //console.log('不等于')
              }

              this.setData({
                tems4: tems4
              })


            }
            // else if (site[s].name == '不包地址') {


            //   //console.log('不包地址')
            // }
          }

          console.log('包地址')
        }

        if (site[1].checked == true) {

          for (var s = 0; s < site.length; s++) {
            if (site[s].name == '不包地址') {
              var tt = {
                money: array[a].money,
                name: array[a].name
              }
              //console.log(tt.money == 0)  

              if (tt.money == 0) {
                //console.log(tt.money)  

                //console.log('你个穷光蛋')

                tt.money = '免费'
                tems4.push(tt)

              } else {
                tt.money = '￥' + tt.money
                tems4.push(tt)

                //console.log(tt.money)

                //console.log('不等于')
              }
            }

            this.setData({
              tems4: tems4
            })

          }


          console.log('不报地址')


        }


        //console.log(this.data.site.id)

        //console.log(id)



      }

    }
    //console.log(id)
    //console.log(name)
    //console.log(this.data.array)
    console.log('picker发送选择改变，携带值为', e.detail.value)


    this.setData({
      index: e.detail.value,
      tems4: tems4
    })
  },

  // 财务服务
  radioChange3: function (e) {
    var isShow = this.data.isShow
    var isShow2 = this.data.isShow2
    var finance = this.data.finance;
    for (var i = 0; i < finance.length; ++i) {
      finance[i].checked = finance[i].value == e.detail.value
      if (finance[i].checked != true) {


        isShow = true;
        isShow2 = true;
        //console.log('打开')
      } else if (finance[i].checked == true) {
        isShow = false;
        isShow2 = false;

        //console.log('关闭')
      }
    }


    //console.log(finance)

    this.setData({
      finance: finance,
      isShow: isShow,
      isShow2: isShow2,
    });

  },

  // 缴费周期
  radioChange4: function (e) {

    var pay_fees = this.data.pay_fees;

    for (var i = 0; i < pay_fees.length; ++i) {

      pay_fees[i].checked = pay_fees[i].value == e.detail.value

    }
    //console.log(pay_fees)

    var checkboxItems = this.data.checkboxItems;

    var istrue = this.data.istrue



    if (pay_fees[0].checked != true) {
      //console.log('bush')  
      //console.log(checkboxItems[0].color)
      checkboxItems[0].color = false
      checkboxItems[1].color = false
      checkboxItems[2].color = false

      // checkboxItems[0].checked = true
      // checkboxItems[1].checked = true
      // checkboxItems[2].checked = true


    } else if (pay_fees[0].checked == true) {
      checkboxItems[0].color = '#3296fa'
      checkboxItems[1].color = '#3296fa'
      checkboxItems[2].color = '#3296fa'

      checkboxItems[0].checked = false
      checkboxItems[1].checked = false
      checkboxItems[2].checked = false

    }

    //console.log(this.data.pay_fees)



    this.setData({
      pay_fees: pay_fees,
      checkboxItems: checkboxItems
    });

  },

  disableds: function (event) {

  },



  //财务增值服务
  checkboxChange: function (event) {

    var checkboxItems = this.data.checkboxItems;
    //获取临时假数据
    //console.log(event)
    var id = [];
    var tems6 = []

    var radioName = event.detail.value
    //获取选中的按钮名称

    //console.log(radioName)
    // console.log(id)
    // console.log(event)
    var istrue = this.data.istrue
    var pay_fees = this.data.pay_fees;
    //console.log(checkboxItems.checked)
    //获取标签id
    for (var i = 0; i < event.detail.value.length; i++) {
      var idNum = event.detail.value[i].split(',');
      id = id.concat(idNum[1])
    }
    for (var y = 0; y < checkboxItems.length; y++) {
      if (id.indexOf(y + "") != -1) {
        checkboxItems[y].checked = true;
      } else {
        checkboxItems[y].checked = false;
      }

      //判断缴费周期是否选中的是季度 是就提醒缴费周期半年以上
      if (pay_fees[0].checked == true) {
        //console.log(istrue)
        checkboxItems[0].checked = istrue
        checkboxItems[1].checked = istrue
        checkboxItems[2].checked = istrue
        if (radioName == '账本账册,0' || radioName == '汇算清缴,1' || radioName == '年检公示,2') {
          wx.showToast({
            title: '此服务需缴费周期半年以上',
            icon: 'none',
            duration: 1500
          })
          //console.log('0000')
        }
        // ----------------
        // if(radioName == '税盘托管,3'){
        //   console.log('税盘')
        // }else if(radioName == '财务额外费用,4'){
        //   console.log('财务额外费用')
        // }
        var tt = {}
        var tt2 = {}
        for (var a = 0; a < id.length; a++) {
          console.log(id)

          if (id[a] == checkboxItems[y].id) {

            //console.log('3')
            tt = {
              money: checkboxItems[3].money,
              name: checkboxItems[3].name,
              num: checkboxItems[3].num,
              cycle: checkboxItems[3].cycle
            }

            tt.name = tt.name + '('
            tt.cycle = tt.cycle + ')'
            tt.money = '￥' + tt.money + 'x'
            //console.log(tt)
            tems6.push(tt)

          } else if (id[0] == 3 && id[1] == 4) {

            // for(var s = 0; s<checkboxItems.length;s++){

            //   if(checkboxItems[s].id == 3 && checkboxItems[s].id == 4){

            //     tt = {
            //       money: checkboxItems[3].money,
            //       name: checkboxItems[3].name,
            //       num: checkboxItems[3].num,
            //       cycle: checkboxItems[3].cycle
            //     }

            //     tt2 = {
            //       money: checkboxItems[4].money,
            //       name: checkboxItems[4].name,
            //       num: checkboxItems[4].num,
            //       cycle: checkboxItems[4].cycle
            //     }


            //     tt.name = tt.name + '('
            //     tt.cycle = tt.cycle + ')'
            //     tt.money = '￥' + tt.money + 'x'
            //     //console.log(tt)

            //     tems6.push(tt)
            //     tems6.push(tt2)

            //     console.log('3he4')
            //   }
            //}


          }
          this.setData({
            tems6: tems6
          })

        }



        // if (id == checkboxItems[y].id) {
        //   //console.log(checkboxItems[y].id)
        //   //console.log(id)
        //   //判断是不是前三个 是则没有数据
        //   if (id == 0 || id == 1 || id == 2) {

        //     var tt = {
        //       money: '',
        //       name: '',
        //       num: '',
        //       cycle: ''
        //     }
        //     tems6.push(tt)

        //   } else {

        //     var tt = {
        //       money: checkboxItems[y].money,
        //       name: checkboxItems[y].name,
        //       num: checkboxItems[y].num,
        //       cycle: checkboxItems[y].cycle
        //     }

        //     tt.name = tt.name + '('
        //     tt.cycle = tt.cycle + ')'
        //     tt.money = '￥' + tt.money + 'x'
        //     tems6.push(tt)

        //   }
        //   //console.log(tems6) 
        //   // 输出到页面
        //   this.setData({
        //     tems6: tems6
        //   })
        //     //console.log(tt)
        //     //console.log(id)
        // }

      } else {

        // if (id == checkboxItems[y].id) {
        //     var tt = {
        //       money: checkboxItems[y].money,
        //       name: checkboxItems[y].name,
        //       num: checkboxItems[y].num,
        //       cycle: checkboxItems[y].cycle
        //     }
        //     tt.name = tt.name + '('
        //     tt.cycle = tt.cycle + ')'
        //     tt.money = '￥' + tt.money + 'x'
        //     tems6.push(tt)

        //   this.setData({
        //     tems6: tems6
        //   })

        //   console.log(tt)
        //   console.log(id)

        // }



      }

    }

    this.setData({
      checkboxItems: checkboxItems

    });
  },


  //增值服务
  checkboxChange2: function (event) {

    var addServer = this.data.addServer;
    // var istrue = false;

    var id = [];

    //获取标签id
    for (var i = 0; i < event.detail.value.length; i++) {
      var idNum = event.detail.value[i].split(',');
      id = id.concat(idNum[1])
    }
    for (var y = 0; y < addServer.length; y++) {
      if (id.indexOf(y + "") != -1) {
        addServer[y].checked = true;
      } else {
        addServer[y].checked = false;
      }
    }



    this.setData({
      addServer: addServer
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})